#include <iostream>
#include <string>
#include <jsoncpp/json/json.h>

using namespace std;
struct Person
{
    /* data */
    int age;
    int score;
    char name;
};

int main()
{
    // 序列化
    // Person p = {25, 150, 'm'};
    // Json::Value root;
    // root["age"] = p.age;
    // root["score"] = p.score;
    // root["name"] = p.name;

    // Json::FastWriter writer;
    // // Json::StyledWriter writer;
    // string json_string = writer.write(root);
    // cout << json_string << endl;

    // 反序列化
    Person p = {0};
    string json_string = R"({"age":25,"name":109,"score":150})";
    Json::Value root;
    Json::Reader reader;
    reader.parse(json_string, root);
    p.age = root["age"].asInt();
    p.score = root["score"].asInt();
    p.name = (char)root["name"].asInt();

    cout << p.age << " " << p.score << " " << p.name << endl;

    return 0;
}